namespace SolidMvvm {
	using System;
	using System.Windows;
	using System.Windows.Markup;

	/// <summary>
	///     This code came from Andre Luus at this blog post:
	///     http://stackoverflow.com/questions/2901664/how-do-i-alter-the-default-Style-of-a-button-without-wpf-reverting-from-aero-to-c/3093183#3093183
	/// </summary>
	[MarkupExtensionReturnType(typeof(object))]
	public class MarkupExtensionStaticApplicationResource : MarkupExtension {
		public MarkupExtensionStaticApplicationResource(object pResourceKey) {
			mResourceKey = pResourceKey;
		}

		[ConstructorArgument("pResourceKey")]
		public object mResourceKey { get; set; }

		public override object ProvideValue(IServiceProvider serviceProvider) {
			return mResourceKey == null || Application.Current == null ? null : Application.Current.TryFindResource(mResourceKey);
		}
	}
}
